package com.bw.mvvm.network.inteceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class ErroInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Response proceed = chain.proceed(request);
        if (proceed.code() == 200)
            return proceed;
        Response.Builder builder = new Response.Builder();
        builder.code(200);
        builder.headers(proceed.headers());
        builder.message(proceed.message());
        builder.protocol(proceed.protocol());
        builder.body(proceed.body());
        return builder.build();
    }
}
